package com.wang.tool.monitor.sample;

import com.wang.tool.trace.TraceHolder;

import java.util.Random;

public class SimpleLinkSampler implements LinkSampler {

    public static Random random = new Random();


    @Override
    public boolean isHitSampling(String group, String biz, String action, long beginTime) {
        String traceId = TraceHolder.getTraceId();
        if (traceId == null) {
            return random.nextInt(1000) == 0;
        }
        return traceId.hashCode() % 1000 == 0;
    }


}
